<template>
    <Form :model="sonar" label-position="top" ref="sonarForm" :rules="sonarRule">
        <Row :gutter="16">
            <Col span="12">
                <FormItem label="Sonar地址" prop="host.url">
                    <Input v-model="sonar.host.url" placeholder="http://sonar.com:80"></Input>
                </FormItem>
            </Col>
            <Col span="12">
                <FormItem label="Token" prop="login">
                    <Input v-model="sonar.login" placeholder="token"></Input>
                </FormItem>
            </Col>
        </Row>
    </Form>
</template>

<script>
    export default {
        data(){
            return {
                sonar:{
                    host:{
                        url: '',
                    },
                    login: ''
                },
                sonarRule:{
                    'host.url': [{
                        required: true, message: 'sonar地址不能为空', trigger: 'blur'
                    }],
                    'login': [{
                        required: true, message: 'token不能为空', trigger: 'blur'
                    }],
                }
            }
        },
        props:['tempApp'],
        created(){

        },
        methods:{
            initData(data){
                this.sonar = data;
            },
            getData(){
                return new Promise((resolve)=>{
                    this.$refs['sonarForm'].validate((valid)=>{
                        if (valid) {
                            resolve({
                                code: 'sonar',
                                groupName: 'Sonar by Gradle',
                                config: JSON.stringify(this.sonar)
                            });
                        }
                    })
                })
            }
        }
    }
</script>

<style scoped>

</style>